package com.shf.mapper;

import com.shf.entity.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Permission持久层
 *
 * @author 叶枫
 */
public interface PermissionMapper {
    /**
     * 查询所有permission
     * @return
     */
    @Select("select *from permission")
    List<Permission> findAllPermission();

    /**
     * 删除角色资源关系表数据 根据 roleid
     * @param id
     */
    @Delete("delete from role_permission where roleId = #{id}")
    void deleteRolePermission(String id);

    /**
     * 多选删除关系表
     * @param ids
     */
    void deleteManyRolePermission( @Param("ids") String[] ids);

    /**
     * 添加权限
     * @param permission
     */
    @Insert("insert into permission values (#{id},#{permissionName},#{url})")
    void addPermission(Permission permission);

    /**
     * 根据id删除权限
     * @param id
     */
    @Delete("delete from permission where id=#{id}")
    void deletePermissionById(String id);

    /**
     * 多选删除权限
     * @param ids
     */
    void deletManyPermission( @Param("ids") String[] ids);
}
